<?php

declare (strict_types=1);

namespace app\api\controller;

use app\common\model\ExchangeCode;
use app\common\model\ExchangeLog;
use think\response\Json;
use cores\exception\BaseException;

/**
 * 兑换中心
 * Class Coupon
 * @package app\api\controller
 */
class Exchange extends Controller
{

    public function exchange(): Json
    {
        $model = new \app\api\model\Exchange();
        if ($model->echange($this->postForm())) {
            return $this->renderSuccess([], '兑换成功');
        }
        return $this->renderError($model->getError() ?: '兑换失败');
    }
}